﻿using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using CallCenter.Data;
using CallCenter.Data.BizUtilities;
using System.Configuration;
using System.Data;
using CallCenter.Security;
using CallCenter.Data.Models;
using CallCenter.Data.Misc;
//using iTextSharp.text.pdf;
//using iTextSharp.text;
using System.Globalization;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Web.Caching;
using iTextSharp.text.pdf;
using iTextSharp.text;
using System.Web.UI.WebControls;
using CallCenter.Data.Helper;
using System.Collections;
//using;
namespace CallCenter.Web.Controllers
{
    public class VendorController : BaseController
    {
        // GET: Vendor
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult VendorCompanyHistory()
        {
            VendorGridVM cmpy = new VendorGridVM();
            return View(cmpy);
        }


        public JsonResult GetVendorCompanies(VendorGridVM model)
        {
            var scratchPads = this.Bridge.VendorUtility.GetAllVendorCompanies();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult GetAllVendorProducts(int id)
        {
            var scratchPads = this.Bridge.VendorUtility.GetAllVendorComProducts(id);
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }



        [HttpPost]
        public JsonResult CreateVendorProducts(ProductGridViewModel model)
        {
            var scratchPads = this.Bridge.VendorUtility.InsertToVendorProduct(model);
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult UpdateVendorProducts(ProductGridViewModel model)
        {
            var scratchPads = this.Bridge.VendorUtility.UpdateToVendorroduct(model);
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }


        [HttpPost]
        public JsonResult DeleteAddProduct(ProductGridViewModel model)
        {
            //insert items into respective tables
            int id = model.id;
            this.Bridge.ProductsUtility.Delete(id);
            var returnMessage = "Success";
            return Json(returnMessage, JsonRequestBehavior.AllowGet);

        }
    }
}